package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsRegion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class DtsRegionServiceImpl implements DtsRegionService {
    @Autowired
    private DtsRegionMapper regionMapper;


    @Override
    public IPage<DtsRegion> queryByPage(Integer id, String name,
                                       Integer page, Integer limit) {
        IPage<DtsRegion> dtsRegionPage = new Page<>(page, limit);
        //条件
        QueryWrapper<DtsRegion> queryWrapper = new QueryWrapper<>();

        if (!StringUtils.isEmpty(id)) {
            queryWrapper.eq("id", id);
        }

        if (!StringUtils.isEmpty(name)) {
            queryWrapper.like("name", name);
        }


        IPage<DtsRegion> regionIPage = regionMapper.selectPage(dtsRegionPage, queryWrapper);

        return regionIPage;
    }
}
